package com.ym521.logdog.engine

import android.util.Log
import com.ym521.logdog.core.ILogDogFormatEngine
import com.ym521.logdog.core.IPrintLogEngine


/**
 * @author YM
 * @E-mail 2435970206@qq
 * @QQ 2435970206
 * 日志打印引擎
 */
internal class PrintLogEngine private constructor() : IPrintLogEngine {
    private val formatEngine: ILogDogFormatEngine = LogDogFormatEngine.build()

    companion object {
        fun build(): IPrintLogEngine {
            return PrintLogEngine()
        }
    }

    override fun logPrint(priority: Int, tag: String, msg: String) {
        val logPriority = when (priority) {
            LogDogEngine.DEBUG -> Log.DEBUG
            LogDogEngine.INFO -> Log.INFO
            LogDogEngine.WARN -> Log.WARN
            LogDogEngine.ERROR, LogDogEngine.CRASH -> Log.ERROR
            else -> Log.VERBOSE
        }
       formatEngine.formatGenerate(msg){
           Log.println(logPriority, tag, it)
       }
    }

}